package com.speedata.testsimple;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.speedata.uhftest.R;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;


/**
 * @author xu  看门狗
 * @date 2022/08/09
 */

public class WatchDogAct extends AppCompatActivity implements View.OnClickListener {


    /**
     *
     */
    private Button bt2;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watchdog);
        initView();

    }


    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onStop() {
        super.onStop();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void initView() {

        bt2 = findViewById(R.id.bt2);
        bt2.setOnClickListener(this);

    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt2:
                try {
                    Log.d("xuyanshuai", "watchdog");
                    String factoryMode = "/sys/devices/platform/function_gpio/watchdog";

                    BufferedWriter mCtrlFile = new BufferedWriter(new FileWriter(factoryMode, false));
                    mCtrlFile.write("1");
                    mCtrlFile.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
            default:
                break;
        }
    }
}
